<template>
  <!-- 基础信息设置 -->
  <div class="organization_basic">
    <el-form
      ref="form"
      label-position="left"
      label-width="180px"
      :model="form"
      :size="formItemSize"
    >
      <el-form-item :label="$t('institutionSetting.jigou6') + '：'" prop="">
        <span>{{ form.name || '' }}</span>
      </el-form-item>
      <el-form-item :label="$t('institutionSetting.jigou7') + '：'" prop="">
        <span>{{
          form.organizedType == 1 ? $t('add.add75') : $t('institutionSetting.jigou9')
        }}</span>
      </el-form-item>
      <el-form-item :label="$t('institutionSetting.jigou10') + '：'" prop="">
        <el-input
          v-model="form.address"
          style="width: 320px"
          :placeholder="$t('institutionSetting.jigou11')"
        />
      </el-form-item>
      <el-form-item :label="$t('institutionSetting.jigou12') + '：'" prop="">
        <el-input
          v-model="form.contact"
          style="width: 320px"
          :placeholder="$t('institutionSetting.jigou13')"
        />
      </el-form-item>
      <el-form-item :label="$t('institutionSetting.jigou14') + '：'" prop="">
        <el-input
          v-model="form.mobile"
          style="width: 320px"
          :placeholder="$t('institutionSetting.jigou15')"
        />
      </el-form-item>
      <el-form-item :label="$t('add.add76') + '：'" prop="">
        <el-switch
          v-model="form.autoCheckState"
          active-color="#003E67"
          inactive-color="#C5C5C5"
          :active-value="1"
          :inactive-value="0"
        />
      </el-form-item>

      <el-form-item v-if="user_organizedType == 2" :label="$t('add.add77') + '：'" prop="">
        <el-switch
          v-model="form.partnerAutoCheck"
          active-color="#003E67"
          inactive-color="#C5C5C5"
          :active-value="1"
          :inactive-value="0"
        />
      </el-form-item>
      <el-form-item v-if="user_organizedType == 2" :label="$t('personPre.pianhao4') + '：'" prop="">
        <el-switch
          v-model="form.auditReportState"
          active-color="#003E67"
          inactive-color="#C5C5C5"
          :active-value="1"
          :inactive-value="0"
        />
      </el-form-item>
      <!-- <el-form-item :label="$t('add.add78') + '：'" prop="">
        <el-switch
          v-model="form.orderDesignAutoCheck"
          active-color="#003E67"
          inactive-color="#C5C5C5"
          :active-value="1"
          :inactive-value="0"
        />
      </el-form-item> -->
      <el-form-item :label="$t('institutionSetting.jigou17') + '：'" prop="">
        <el-switch
          v-model="form.sendOrderState"
          active-color="#003E67"
          inactive-color="#C5C5C5"
          :active-value="1"
          :inactive-value="0"
        />
      </el-form-item>

      <!-- <el-form-item label="加入成员有效期天数：" prop="">
                <el-input style="width:320px" v-model="form.account" placeholder="请输入天数"/>
            </el-form-item> -->
    </el-form>
    <div class="organization_basic_bottom">
      <el-button type="primary" :size="optionButtonSize" @click="submitHandle">{{
        $t('institutionSetting.jigou18')
      }}</el-button>
      <el-button plain :size="optionButtonSize" @click="cancleHandle">{{
        $t('institutionSetting.jigou19')
      }}</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BLZMasterBasicinfo',
  components: {
    // Upload,
  },
  data() {
    return {
      form: {
        address: '',
        autoCheckState: '1',
        checkStatus: '',
        checkStatusName: '',
        contact: '',
        createDate: '',
        creator: 0,
        currentDept: true,
        delFlag: 0,
        id: 0,
        mobile: '',
        name: '',
        organizedType: '',
        queryType: '',
        remark: '',
        roleId: 0,
        sendOrderState: null,
        updateDate: '',
        userDeptRoleId: 0,
        userId: 0,
        partnerAutoCheck: null,
        // orderDesignAutoCheck: null,
        auditReportState: 0,
      },
      user_organizedType: '',
    };
  },

  mounted() {
    this.getOrganized();
    this.user_organizedType = localStorage.getItem('user_organizedType'); // 1诊所 2技工所
  },

  methods: {
    getOrganized() {
      this.$http
        .get(`/sys/organized/${localStorage.getItem('user_jg_id')}`)
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            this.form = res.data;
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    },
    // 保存
    submitHandle() {
      this.$http
        .put('sys/organized/update', this.form)
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
  
            this.$message.success(this.$t('institutionSetting.jigou20'));
            // this.getOrganized()
            this.$EventBus.$emit("refreshInstitution");
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    },
    // 取消
    cancleHandle() {
      this.getOrganized();
    },
  },
};
</script>

<style lang="scss" scoped>
.organization_basic {
  padding-top: 15px;

  .organization_basic_bottom {
    padding-top: 15px;
    padding-bottom: 50px;
  }
}
</style>
